const pkg = require('pkg');
const path = require('path');
const fs = require('fs-extra');
const concurrently = require('concurrently');

class TaskMap {
    build() {
        concurrently(['webpack --mode production --config ./build/index.js']);
    }

    pkg() {
        pkg.exec(['--compress', '--output', path.resolve(__dirname, '..', 'bin', 'tt'), path.resolve(__dirname, 'dist', 'index.js')]);
    }
}

function run() {
    const args = process.argv;
    if (args && args.length >= 2) {
        const taskMap = new TaskMap();
        const argArray = args.slice(2);
        const [task] = argArray;
        taskMap[task]();
    }
}

run();
